package game.model.building
{
	import game.model.building.vo.BuildingConfigVO;
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;

	/**
	 * ...
	 * @author Thot
	 */
	
	public class BuildingConfigProxy extends Proxy implements IProxy
	{
		
		static public var NAME:String = 'BuildingConfigProxy';
		private var _data:Vector.<BuildingConfigVO>;
		
		public function BuildingConfigProxy()
		{ 
			_data = new Vector.<BuildingConfigVO>();
			super( NAME, _data );
		}
		
		public function addBuildingConfig( p_building:BuildingConfigVO ):void
		{
			_data.push( p_building );
		}
		
		public function getBuildingsConfigs():Vector.<BuildingConfigVO>
		{
			return _data;
		}
		
		public function getBuildingConfigBy( p_prop:String, p_value:* ):BuildingConfigVO
		{
			var i:int = _data.length;
			var building:BuildingConfigVO = null;
			
			while ( --i > -1 )
			{
				building = _data[i];
				if ( building.hasOwnProperty(p_prop) && building[p_prop] == p_value )
					return building;
			}
			
			return null;
		}
		
		
	}

}